import javax.swing.*;

//多线程
public class duoxianc {
    public static void button1(JButton button) {
        Thread person1 = new Thread(new Runnable() {
            @Override
            public void run() {
                simulateButtonClick(button);
            }
        });

        Thread person2 = new Thread(new Runnable() {
            @Override
            public void run() {
                simulateButtonClick(button);
            }
        });

        // 启动线程
        person1.start();
        person2.start();
    }

    private static void simulateButtonClick(final JButton button) {
        try {
            // 确保点击事件在事件分发线程（EDT）上执行
            SwingUtilities.invokeAndWait(new Runnable() {
                @Override
                public void run() {
                    // 模拟按钮点击
                    button.doClick();
                }
            });
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}